<%--
  Created by IntelliJ IDEA.
  User: Dell
  Date: 2025/7/1
  Time: 10:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
    <title>发布寄养家庭</title>
    <style>
        /* 保持与提交申请页面一致的样式 */
        .alert {
            padding: 15px;
            margin-bottom: 20px;
            border: 1px solid transparent;
            border-radius: 4px;
        }
        .alert-warning {
            color: #8a6d3b;
            background-color: #fcf8e3;
            border-color: #faebcc;
        }
        .btn-primary {
            color: #fff;
            background-color: #337ab7;
            border-color: #2e6da4;
            padding: 6px 12px;
            border-radius: 4px;
            text-decoration: none;
            display: inline-block;
        }
        .download-btn {
            display: inline-block;
            background-color: #4CAF50;
            color: white;
            padding: 8px 15px;
            border-radius: 4px;
            text-decoration: none;
            transition: background-color 0.3s;
            margin-bottom: 15px;
        }
        .download-btn:hover {
            background-color: #45a049;
        }
        .form-group {
            margin-bottom: 20px;
        }
        label {
            display: block;
            margin-bottom: 8px;
            font-weight: 500;
            color: #5D4037;
        }
        input, textarea, select {
            width: 100%;
            padding: 12px 15px;
            border: 1px solid #FFECB3;
            border-radius: 8px;
            font-size: 16px;
        }
        .form-row {
            display: flex;
            gap: 20px;
        }
        .form-col {
            flex: 1;
        }
    </style>
</head>
<body>
<jsp:include page="/WEB-INF/views/user/head.jsp"/>
<div class="container">
    <h1>发布寄养家庭</h1>

    <c:if test="${needsApproval}">
        <div class="alert alert-warning">
            <p>您需要先提交并通过服务申请审核才能发布寄养家庭服务。</p>

            <!-- 添加下载链接 -->
            <div>
                <a href="${pageContext.request.contextPath}/static/documents/申请表.docx"
                   download="寄养家庭申请表.docx"
                   class="download-btn">
                    <i class="fas fa-download"></i> 下载申请表格
                </a>
            </div>

            <p>请下载并填写上方表格，然后提交申请</p>
            <a href="${pageContext.request.contextPath}/application/submit?type=HOST" class="btn btn-primary">
                去提交申请
            </a>
        </div>
    </c:if>

   <!-- <form method="post" action="${pageContext.request.contextPath}/Hosts/publish">-->
        <form method="post" action="${pageContext.request.contextPath}/Hosts/publish" enctype="multipart/form-data">
            <div class="form-group">
                <label for="familyName">家庭名称 <span style="color: red;">*</span></label>
                <input type="text" id="familyName" name="family_name" required>
            </div>

            <div class="form-row">
                <div class="form-col">
                    <label for="serviceTypes">服务类型 <span style="color: red;">*</span></label>
                    <input type="text" id="serviceTypes" name="service_types" placeholder="例如：狗狗寄养、猫咪寄养" required>
                </div>
                <div class="form-col">
                    <label for="location">所在位置 <span style="color: red;">*</span></label>
                    <input type="text" id="location" name="location" placeholder="例如：北京市朝阳区" required>
                </div>
            </div>

            <div class="form-row">
                <div class="form-col">
                    <label for="price">每日价格(元) <span style="color: red;">*</span></label>
                    <input type="number" id="price" name="price" min="0" step="0.1" required>
                </div>
                <div class="form-col">
                    <label for="applicationId">申请ID</label>
                    <input type="number" id="applicationId" name="application_id" readonly value="${applicationId}">
                </div>
            </div>

            <div class="form-group">
                <label for="description">家庭描述 <span style="color: red;">*</span></label>
                <textarea id="description" name="description" placeholder="请详细描述您的家庭环境、宠物照顾经验等信息..." required></textarea>
            </div>
            <div class="form-group">
                <label for="env">环境图片</label>
                <input type="file" id="env" name="envImages" multiple accept="image/*">
            </div>

            <div class="form-group" style="text-align: center;">
                <button type="submit" class="btn" ${needsApproval ? 'disabled' : ''}>
                    <i class="fas fa-publish"></i> 发布寄养家庭
                </button>
                <a href="${pageContext.request.contextPath}/Hosts/list" class="btn back-btn">
                    <i class="fas fa-arrow-left"></i> 返回列表
                </a>
            </div>
        </form>
        <!--<button type="submit" class="btn btn-primary" ${needsApproval ? 'disabled' : ''}>发布</button>-->
    </form>
</div>

</body>
</html>